package encapsulation;

/**
 * @classname:Member
 * @description:
 * @author: Mr.Z
 * @date: 2020/11/28 10:27
 * @version: 0.1
 * @since:1.8
 */

public class Member {
    private int number;
    private String name;
    private int integral;
    public Member() {
    }

    public Member(int number, String name, int integral) {
        this.number = number;
        this.name = name;
        this.integral = integral;
    }

    public int getNumber() {
        return number;
    }

    public void setNumber(int number) {
       register(number);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getIntegral() {
        return integral;
    }

    public void setIntegral(int integral) {
        this.integral = integral;
    }

    public int  register(int number){
        if(number>9999||number<1000){
            System.out.println("会员账号不合法正在退出...");
            return 1;
        }else{
            this.number=number;
        }
        return 0;
    }
    public String discount(){
        if(this.integral<1000){
            return "九折优惠";
        }else if(1000<=this.integral||this.integral<2000){
            return "八折优惠";
        }else if(2000<=this.integral||this.integral<3000){
            return "七折优惠";
        }else if(this.integral>=3000){
            return "六折优惠";
        }
        return "不享受优惠";
    }

    public boolean isLucy(){
        int random= (int)((Math.random()*9+1)*1000);
        if(this.number==random){
            return true;
        }
        return false;
    }
}
